package org.microblog;

import org.junit.Test;
import org.microblog.dao.UserDao;
import org.microblog.dao.impl.UserDaoImpl;
import org.microblog.entity.User;
import org.microblog.service.UserService;
import org.microblog.service.impl.UserServiceImpl;
import org.microblog.util.DatabaseUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.Date;
import java.sql.SQLException;

/**
 * @author 许欣
 * 时间：2022/4/23 9:32
 * 描述：
 */
public class Test01 {
    @Test
    public void getAll() throws SQLException {
//        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserService dao= (UserService) context.getBean("userService");
//        User list=dao.findUser("15210085665", "123456");
//        System.out.println(list.getName());
        User user=new User();
        user.setUserId("15210085665");
        user.setPassword("123456");
        user.setNickname("张三");
        user.setImage("images/headicon2.jpg");
        user.setName("悠");
        user.setBirthday(new Date(2000-06-02));
        user.setEmail("123456@qq.com");
        user.setCreatetime(new Date(2016-01-01));
        user.setIspublic(null);
//        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserService dao= (UserService) context.getBean("userService");
        UserService dao=new UserServiceImpl();
        int list=dao.register(user);
        if (list>0){
            System.out.println("添加成功");
        }else {
            System.out.println("失败");
        }

    }
}
